#include<iostream>
#include<math.h>
using namespace std;
class Triangle {
private:
	double a, b, c;
public:
	void Init(double sideA, double sideB, double sideC);
	bool isTriangle();
	double getsideA();
	void setsideA(double sideA);
	double getsideB();
	void setsideB(double sideB);
	double getsideC();
	void setsideC(double sideC);
	double perimeter();
	double area();
	int typeTriangle();
};
void Triangle::Init(double sideA, double sideB, double sideC) {
	a = sideA;
	b = sideB;
	c = sideC;
}
bool Triangle::isTriangle() {
	return (a + b > c) && (a + c > b) && (b + c > a);
}
double Triangle::getsideA() {
	return a;
}
void Triangle::setsideA(double sideA) {
	a = sideA;
}
double Triangle::getsideB() {
	return b;
}
void Triangle::setsideB(double sideB) {
	b = sideB;
}
double Triangle::getsideC() {
	return c;
}
void Triangle::setsideC(double sideC) {
	c = sideC;
}
double Triangle::perimeter() {
	return a + b + c;
}
double Triangle::area() {
	double p = perimeter() / 2;
	return sqrt(p * (p - a) * (p - b) * (p - c));
}
int Triangle::typeTriangle() {
	double maxSide = max(max(a, b), c);
	double sumSquares = 0;
	if (maxSide == a) {
		sumSquares = b * b + c * c;
	}
	else if (maxSide == b) {
		sumSquares = a * a + c * c;
	}
	else {
		sumSquares = a * a + b * b;
	}
	double maxSideSquare = maxSide * maxSide;
	if (maxSideSquare == sumSquares) {
		return 0;
	}
	else if (maxSideSquare < sumSquares) {
		return 1;
	}
	else {
		return 2;
	}
}
int main() {
	Triangle tri;
	tri.Init(3, 4, 5);
	if (tri.isTriangle()) {
		cout << "能构成三角形" << endl;
		cout << "周长：" << tri.perimeter() << endl;
		cout << "面积：" << tri.area() << endl;
		int type = tri.typeTriangle();
		cout << "三角形类型：";
		switch (type) {
		case 0:cout << "直角三角形" << endl; break;
		case 1:cout << "锐角三角形" << endl; break;
		case 2:cout << "钝角三角形" << endl; break;
		}
	}else {
		cout << "不能构成三角形" << endl;
	}
	tri.setsideA(5);
	tri.setsideB(5);
	tri.setsideC(5);
	if (tri.isTriangle()) {
		cout << "能构成三角形" << endl;
		cout << "周长：" << tri.perimeter() << endl;
		cout << "面积：" << tri.area() << endl;
		int type = tri.typeTriangle();
		cout << "三角形类型：";
		switch (type) {
		case 0:cout << "直角三角形" << endl; break;
		case 1:cout << "锐角三角形" << endl; break;
		case 2:cout << "钝角三角形" << endl; break;
		}
	}
	else {
		cout << "不能构成三角形" << endl;
	}
	cout << "读取边长 a:" << tri.getsideA() << endl;
	cout << "读取边长 b:" << tri.getsideB() << endl;
	cout << "读取边长 c:" << tri.getsideC() << endl;
	Triangle invalidTri;
	invalidTri.Init(1, 2, 3);
	if (invalidTri.isTriangle()) {
		cout << "能构成三角形" << endl;
	}
	else {
		cout << "三边不能构成三角形" << endl;
	}
	return 0;
}